import { resolve } from 'path';
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import vueDevTools from 'vite-plugin-vue-devtools';
import AutoImport from 'unplugin-auto-import/vite';
import Components from 'unplugin-vue-components/vite';
import ElementPlus from 'unplugin-element-plus/vite';
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers';
// https://vite.dev/config/
export default defineConfig(function (_a) {
    var mode = _a.mode;
    return {
        // root: env.VITE_APP_ROOTPATH,
        plugins: [
            vue(),
            vueDevTools(),
            ElementPlus({
                useSource: true, // 启用源码样式，支持主题定制
            }),
            // Element自动导入
            AutoImport({
                imports: ["vue", "vue-router"],
                resolvers: [ElementPlusResolver()],
            }),
            Components({
                resolvers: [ElementPlusResolver({ importStyle: "sass" })],
            }),
        ],
        css: {
            preprocessorOptions: {
                scss: {
                    additionalData: "@use \"@/styles/variable.scss\" as *;\n             @use \"@/styles/element/index.scss\";\n            ", //它用于向每个 SCSS 文件中自动注入一些公共的 CSS 代码
                },
            },
        },
        resolve: {
            extensions: [".js", ".ts", ".vue", ".json"],
            alias: {
                "@": resolve(__dirname, "src"),
                "@manager": resolve(__dirname, "src/modules/manager"),
                "@reader": resolve(__dirname, "src/modules/reader"),
            },
        },
        build: {
            target: ['chrome89', 'edge89', 'firefox89', 'safari15'],
            rollupOptions: {
                input: {
                    index: resolve(__dirname, 'index.html'),
                    reader: resolve(__dirname, 'reader.html')
                },
                output: { dir: "./dist" },
            },
        },
    };
});
